package com.kata.chapter5;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by Solidsnake on 2014/11/17.
 */
public class FileReadPool {

    static class FileRead {
        private int fileCount;
        private FileRead() {
            System.out.println("开始装载...");
        }
        private FileRead(int fileCount) {
           this();
           this.fileCount = fileCount;
        }

        public void readFile() {
            System.out.println("开始读取" + this.fileCount + "号红头文件...");
        }
    }


    private final static List<FileRead> pool = new ArrayList<FileRead>();

    static {
        pool.add(new FileRead(1));
        pool.add(new FileRead(2));
        pool.add(new FileRead(3));
        pool.add(new FileRead(4));
        pool.add(new FileRead(5));
    }

    public static FileRead getFileRead() {
        Random random = new Random();
        int countNumOfEmperor = random.nextInt(5);
        FileRead target =pool.get(countNumOfEmperor);
        return target;
    }

}


